package com.lanvideo.entity;

import java.time.LocalDateTime;

/**
 * 考试记录实体类
 */
public class ExamRecord {
    private Integer id;
    private Integer examId;
    private String examTitle;
    private Integer studentId;
    private String studentName;
    private Integer score;
    private Integer totalQuestions;
    private LocalDateTime examTime;

    public ExamRecord() {}

    public ExamRecord(Integer studentId, Integer score, Integer totalQuestions) {
        this.studentId = studentId;
        this.score = score;
        this.totalQuestions = totalQuestions;
    }

    // Getters and Setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getExamId() {
        return examId;
    }

    public void setExamId(Integer examId) {
        this.examId = examId;
    }

    public String getExamTitle() {
        return examTitle;
    }

    public void setExamTitle(String examTitle) {
        this.examTitle = examTitle;
    }

    public Integer getStudentId() {
        return studentId;
    }

    public void setStudentId(Integer studentId) {
        this.studentId = studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public Integer getTotalQuestions() {
        return totalQuestions;
    }

    public void setTotalQuestions(Integer totalQuestions) {
        this.totalQuestions = totalQuestions;
    }

    public LocalDateTime getExamTime() {
        return examTime;
    }

    public void setExamTime(LocalDateTime examTime) {
        this.examTime = examTime;
    }

    /**
     * 获取成绩百分比
     */
    public double getScorePercentage() {
        if (totalQuestions == 0) return 0;
        return (double) score / totalQuestions * 100;
    }

    @Override
    public String toString() {
        return "ExamRecord{" +
                "id=" + id +
                ", examId=" + examId +
                ", examTitle='" + examTitle + '\'' +
                ", studentId=" + studentId +
                ", studentName='" + studentName + '\'' +
                ", score=" + score +
                ", totalQuestions=" + totalQuestions +
                ", examTime=" + examTime +
                '}';
    }
}
